<template>
  <div class="wholesale-list block">
    <div class="header">
      <h2 class="title">报台信息管理</h2>
      <el-form ref="queryForm" :inline="true" label-position="right" :model="tableQuery">
        <el-form-item label="报台单号">
          <el-input
            maxlength="30"
            v-model.trim="tableQuery.orderCode"
            type="text"
            placeholder="请输入"
          />
        </el-form-item>

        <el-form-item label="销售对象">
          <el-select
            v-model="tableQuery.saleTargetCode"
            filterable
            maxlength="30"
            remote
            clearable
            placeholder="请输入关键词"
            :remote-method="saleTargetCodeRemoteMethod"
            :loading="loading"
          >
            <el-option
              v-for="(item,num) in saleTargetCodeOptions"
              :key="num"
              :label="item.saleTargetName"
              :value="item.saleTargetCode"
            />
          </el-select>
        </el-form-item>

        <el-form-item label="原厂">
          <el-select
            v-model="tableQuery.originalFactoryCode"
            filterable
            maxlength="30"
            remote
            clearable
            placeholder="请输入关键词"
            :remote-method="originalFactoryCodeRemoteMethod"
            :loading="loading"
          >
            <el-option
              v-for="(item,num) in originalFactoryCodeOptions"
              :key="num"
              :label="item.originalFactoryName"
              :value="item.originalFactoryCode"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model="tableQuery.orderStatus" clearable placeholder="请选择">
            <el-option label="生成" value="21"></el-option>
            <el-option label="冲红" value="22"></el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="报台类型">
          <el-select v-model="tableQuery.busModel" clearable placeholder="请选择">
            <el-option label="批发采购报台" value="1"></el-option>
            <el-option label="长期寄售报台" value="2"></el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label="销售日期">
          <el-date-picker
            v-model="saleDate"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="daterange"
            range-separator="至"
            :default-time="['00:00:00', '23:59:59']"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>

        <el-form-item label="创建报台日期" v-show="collapse">
          <el-date-picker
            v-model="createDate"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="daterange"
            range-separator="至"
            :default-time="['00:00:00', '23:59:59']"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>

        <el-form-item class="form-button">
          <el-button type="text" @click="collapse=!collapse" v-if="height_collapse">
            <span v-if="collapse">
              收起详细查询
              <i class="el-icon-arrow-up" />
            </span>
            <span v-else>
              展开详细查询
              <i class="el-icon-arrow-down" />
            </span>
          </el-button>
          <el-button type="primary" @click="queryFormQuery">查询</el-button>
          <el-button @click="queryFormReset">重置</el-button>
        </el-form-item>
        <div class="clear"></div>
      </el-form>
    </div>
    <section class="el-container container-box is-vertical">
      <div class="operate">
        <el-button type="primary" size="mini" @click="addGo">新建报台</el-button>
        <el-button type="primary" size="mini" @click="exportEx">部分导出</el-button>
        <el-button type="primary" size="mini" @click="exportExAll">全部导出</el-button>
      </div>
      <el-editable
        row-key="orderId"
        :data="payload.content"
        height="400"
        stripe
        ref="tableRef"
        v-loading="tableLoading"
        :columns="listColumns"
        :payload="payload"
        :needPagination="true"
        @reload="reloadProductData"
        @selection-change="selectionChange"
      >
        <template slot="default-operation" slot-scope="scope">
          <el-button type="text" @click="checkDetail(scope.row)">查看</el-button>
          <el-button
            v-if=" Number(scope.row.orderStatus !== 22) && Number(scope.row.redFlag) === 0"
            type="text"
            @click="rushRedDialog(scope.row)"
          >冲红</el-button>
          <el-button
            v-if="Number(scope.row.orderStatus !== 22) && Number(scope.row.redFlag) === 0"
            type="text"
            @click="editGo(scope.row)"
          >编辑</el-button>
        </template>
      </el-editable>
      <el-dialog
        title="冲红"
        custom-class="dialog-custom"
        :visible.sync="delDialogVisible"
        width="40%"
      >
        <h2>是否要对选中的报台信息进行冲红？</h2>
        <p style="text-align: center;">（冲红是指报错销售信息，冲掉已报台物料）</p>
        <div class="delBtn">
          <el-button @click="delDialogVisible = false">取消</el-button>
          <el-button type="primary" :loading="redLoding" @click="rushRedOk">确认</el-button>
        </div>
      </el-dialog>
    </section>
  </div>
</template>

<script src="./index.js"></script>

<style lang="less" src="./index.less" scoped></style>
